import { createApp,Vue } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import "normalize.css"
//  import Directives from './utils/directives/index';
// console.log(Directives);
import Vant from 'vant';
import 'vant/lib/index.css';
const app=createApp(App)
import { Lazyload } from 'vant';
import "./style/base.scss"
import {VueMasonryPlugin} from 'vue-masonry';
const d = {
    mounted: function (el, binding) {
        // console.log(el,binding);
        // if (typeof binding.value !== 'function') {
        //   throw 'callback must be a function'
        // }
    
        // 定义变量
        let pressTimer = null
        // 创建计时器（ 2秒后执行函数 ）
        let start = (e) => {
          if (e.type === 'click' && e.button !== 0) {
            return
          }
          if (pressTimer === null) {
            pressTimer = setTimeout(() => {
              handler()
            }, 1000)
          }
        }
        // 取消计时器
        let cancel = (e) => {
          if (pressTimer !== null) {
            clearTimeout(pressTimer)
            pressTimer = null
          }
        }
        // 运行函数
        const handler = (e) => {
          binding.value(el)
      
        }
        // 添加事件监听器
        el.addEventListener('mousedown', start)
        el.addEventListener('touchstart', start)
        // 取消计时器
        el.addEventListener('click', cancel)
        el.addEventListener('mouseout', cancel)
        el.addEventListener('touchend', cancel)
        el.addEventListener('touchcancel', cancel)
      }
}


app.directive("logopress",d)

app.use(store).use(router).use(Vant).use(VueMasonryPlugin).use(Lazyload, {
  lazyComponent: true,
}).mount('#app')
